package com.tanhua.server.service;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.common.mapper.UserInfoMapper;
import com.tanhua.common.pojo.UserInfo;
import com.tanhua.server.pojo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

/**
 * @program: my-tanhua
 * @description:
 * @author: xuejingjing
 * @create: 2021-09-21 13:36
 **/

@Service
public class UserInfoService {


    @Autowired
    private UserInfoMapper userInfoMapper;

    public UserInfo queryUserInfoByUserId(Long userId) {

        QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        UserInfo userInfo = userInfoMapper.selectOne(queryWrapper);
        if(ObjectUtil.isNotEmpty(userInfo)){
            return userInfo;
        }
        return null;
    }

    public List<UserInfo> queryUserInfoList(QueryWrapper<UserInfo> queryWrapper){
        return userInfoMapper.selectList(queryWrapper);
    }

    /**
     * 根据用户id列表查询用户信息
     * @param userIdList
     * @return
     */
    public List<UserInfo> queryUserInfoByIdList(Collection<?> userIdList) {
        //
        QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("user_id",userIdList);
        return queryUserInfoList(queryWrapper);
    }


    public List<UserInfo> queryUserInfoByUserIdList(List<Object> userIds) {

        return null;
    }


}